package com.ruoyi.dto;

import lombok.Data;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * @author chongjin
 * @date 2023/6/12
 */
@Data
public class ContractSaveDTO {
    /**
     * 合同id
     */
    private String contractId;
    /**
     * 房间id
     */
    private String roomId;
    /**
     * 房间租金
     */
    private BigDecimal roomRent;
    /**
     * 房间押金
     */
    private BigDecimal roomDeposit;
    /**
     * 电费
     */
    private BigDecimal powerRate;
    /**
     * 水费
     */
    private BigDecimal waterRate;
    /**
     * 网络费
     */
    private BigDecimal networkRate;
    /**
     * 卫生费
     */
    private BigDecimal cleanRate;
    /**
     * 电表读数
     */
    private BigDecimal powerNumber;
    /**
     * 水表读数
     */
    private BigDecimal waterNumber;
    /**
     * 签约时间
     */
    private String signDate;
    /**
     * 合同开始时间
     */
    private String beginDate;
    /**
     * 合同截止时间
     */
    private String endDate;
    /**
     * 备注
     */
    private String remark;

    public void setRoomRent(BigDecimal roomRent) {
        this.roomRent = resetScale(roomRent);
    }

    public void setRoomDeposit(BigDecimal roomDeposit) {
        this.roomDeposit = resetScale(roomDeposit);
    }

    public void setPowerRate(BigDecimal powerRate) {
        this.powerRate = resetScale(powerRate);
    }

    public void setWaterRate(BigDecimal waterRate) {
        this.waterRate = resetScale(waterRate);
    }

    public void setNetworkRate(BigDecimal networkRate) {
        this.networkRate = resetScale(networkRate);
    }

    public void setCleanRate(BigDecimal cleanRate) {
        this.cleanRate = resetScale(cleanRate);
    }

    public void setPowerNumber(BigDecimal powerNumber) {
        this.powerNumber = resetScale(powerNumber);
    }

    public void setWaterNumber(BigDecimal waterNumber) {
        this.waterNumber = resetScale(waterNumber);
    }

    private BigDecimal resetScale(BigDecimal bigDecimal) {
        return Objects.isNull(bigDecimal) ? null :
                bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP);
    }
}
